package com.core.util;

import java.io.Serializable; 
import java.util.List;

import org.hibernate.criterion.DetachedCriteria;

public interface GenericService<T , PK extends Serializable> {
	/**
	 * 保存数据
	 * 
	 * @param json
	 * @return
	 */
	public String save(T t) throws Exception;

	/**
	 * 查询
	 * 
	 * @param firstResult
	 * @param maxResults
	 * @return
	 */
	public Pagination<T> find(T entry , int firstResult, int maxResults);
	
	/**
	 * 查询单条记录
	 * @param id
	 * @return
	 */
	public T findById(PK id) ;
	
	/**
	 * 动态模糊查询
	 * @param dc
	 * @param firstResult
	 * @param maxResults
	 * @return
	 */
	public Pagination<T> search(final DetachedCriteria dc , final int firstResult , final int maxResults);

	/**
	 * 删除
	 * 
	 * @param entry
	 *            实体Bean
	 * @return
	 */
	public String delete(T entry);

	/**
	 * 得到总记录数
	 * 
	 * @param condition
	 * @return
	 */
	public int getSize(String condition);

	/**
	 * 修改记录
	 * 
	 * @param entry
	 */
	public String update(T entry) throws Exception;
	
	/**
	 * 按条件查询
	 * @param condition
	 * @return
	 */
	public List<T> getCondition(T entry) ;
	/**
	 * 
	 * @param dc
	 * @return
	 */
	public List<T> likeBy(DetachedCriteria dc);
}